package com.imay.live.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.imay.live.model.SearchTopicModel;
import com.imay.live.view.GridImageLayout;
import com.imay.live.R;

import java.util.List;

/**
 * Created by liangzhenxiong on 2017/4/6 0006.
 * 搜索话题
 */

public class SearchTopicAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {


    public final static int VIEWTYPE_LINEAR_CONTENT = 0x113;//推荐结果


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public SearchTopicAdapter(List<MultiItemEntity> data) {
        super(data);
        addItemType(VIEWTYPE_LINEAR_CONTENT, R.layout.searchtopic_item);

    }


    @Override
    protected void convert(final BaseViewHolder helper, MultiItemEntity item) {
        if (item.getItemType() == VIEWTYPE_LINEAR_CONTENT) {
            SearchTopicModel searchTopicModel = (SearchTopicModel) item;
            helper.setText(R.id.tv_topic_title, helper.getConvertView().getResources().getString(R.string.search_topiccontent, searchTopicModel.getLabelContent()));
            helper.setText(R.id.tv_topic_status, helper.getConvertView().getResources().getString(R.string.search_topiccount, searchTopicModel.getUseCount()));
            helper.addOnClickListener(R.id.tv_topic_info);
            GridImageLayout gridImageLayout = helper.getView(R.id.grid_head);
            gridImageLayout.setModels(searchTopicModel.getFeeds(), searchTopicModel.getLabelContent(), true);
        }
    }
}
